//
//  DBStorageService.h
//  MiniWeChat
//
//  Created by ByteDance on 2025/6/26.
//

#import <Foundation/Foundation.h>
#import "UserModel.h"
#import "ConversationModel.h"
#import "MessageModel.h"

NS_ASSUME_NONNULL_BEGIN

@interface DBStorageService : NSObject

+ (instancetype)sharedInstance;

// 用户相关
- (void)saveUser:(UserModel *)user;
- (void)saveCurrentUser:(UserModel *)user;
- (UserModel *)currentUser;
- (UserModel *)fetchUserById:(NSString *)id;
- (void)removeCurrentUser;

// 聊天会话相关
- (void)fetchConversationById:(NSString *)id completion:(void(^)(ConversationModel *conversation, NSError *error))completion;
- (void)fetchConversationsByUid:(NSString *)uid completion:(void(^)(NSArray<ConversationModel *> *conversations, NSError *error))completion;

- (void)saveConversation:(ConversationModel *)conversation;
//- (void)markMessageAsReadByCid:(NSString *)cid;
//
//// 消息相关
//- (void)fetchMessagesByCid:(NSString *)cid pageSize:(NSInteger)pageSize offset:(NSInteger)offset completion:(void(^)(NSArray<MessageModel *> *messages, NSError *error))completion;
//- (void)sendMessage:(MessageModel *)message completion:(void(^)(NSError *error))completion;


- (NSArray<MessageModel *> *)fetchMessagesByReceiver:(NSString *)receiver completion:(void(^)(NSArray<MessageModel *> *messages, NSError *error)) completion;

- (NSArray<MessageModel *> *)fetchMessagesByConversationId: (NSString *) conversation_id;

- (void)saveMessage: (MessageModel *)message;                                   

@end

NS_ASSUME_NONNULL_END
